#include <iostream>
using namespace std;

#include <string.h>

const int N = 1000010;
char s1[N], s2[N];
int a[N], ne[N];
int main()
{
    // 读入字符串
    cin >> s1 + 1 >> s2 + 1;
    int l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);
    // 求ne[j]的过程
    for (int i = 2, j = 0; i <= l2; i++)
    {
        while (j && s2[i] != s2[j + 1])
        {
            j = ne[j];
        }
        if (s2[i] == s2[j + 1])
        {
            j++;
        }
        ne[i] = j;
    }

    // kmp匹配过程
    for (int i = 1, j = 0; i <= l1; i++)
    {
        while (j && s1[i] != s2[j + 1])
        {
            j = ne[j];
        }
        if (s1[i] == s2[j + 1])
        {
            j++;
        }
        if (j == l2)
        {
            cout << i - l2 + 1 << endl;
            j = ne[j];
        }
    }
    for (int i = 1; i <= l2; i++)
    {
        cout << ne[i] << " ";
    }
    return 0;
}